using System;
using System.Collections.Generic;
using System.Text;
using Entities;
using DAL;
using Utility;

namespace BUS
{
    public class tbTinhTrangGHBUS
    {
        public static void Insert(tbTinhTrangGH tinhtranggiaohang)
        {
            tbTinhTrangGHDAL ttghDAL = new tbTinhTrangGHDAL();
            ttghDAL.Insert(tinhtranggiaohang);
        }
        public static void Update(tbTinhTrangGH tinhtranggiaohang)
        {
            tbTinhTrangGHDAL ttghDAl = new tbTinhTrangGHDAL();
            ttghDAl.Update(tinhtranggiaohang);
        }
        public static void Delete(int iD)
        {
            tbTinhTrangGHDAL ttghDAl = new tbTinhTrangGHDAL();
            ttghDAl.Delete(iD);
        }
        public static tbTinhTrangGHCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbTinhTrangGHDAL ttghDAL = new tbTinhTrangGHDAL();
            return ttghDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbTinhTrangGHCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbTinhTrangGHDAL ttghDAL = new tbTinhTrangGHDAL();
            return ttghDAL.Get(cri.Criter, 0, 0, tbTinhTrangGHColumns.MaTTGH.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbTinhTrangGH GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbTinhTrangGHColumns.MaTTGH.ToString(), Condition.EQUAL, iD);
            tbTinhTrangGHDAL ttghDAL = new tbTinhTrangGHDAL();
            tbTinhTrangGHCollection ttghCollection = ttghDAL.Get(cri.Criter, 0, 0, tbTinhTrangGHColumns.MaTTGH.ToString(), OrderDirection.ASC.ToString(), out total);
            if (ttghCollection.Count > 0)
                return ttghCollection[0];
            return null;
        }
        public static tbTinhTrangGHCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbTinhTrangGHDAL ttghDAL = new tbTinhTrangGHDAL();
            return ttghDAL.Get(cri.Criter, 1, number, tbTinhTrangGHColumns.MaTTGH.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbTinhTrangGHCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbTinhTrangGHDAL ttghDAL = new tbTinhTrangGHDAL();
            return ttghDAL.Get(cri.Criter, 1, number, tbTinhTrangGHColumns.MaTTGH.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}